package com.heima.admin.kafka;

import com.heima.admin.service.WemediaNewsAutoScanService;
import com.heima.common.constants.message.NewsAutoScanConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 王可
 * @Date: 2021/02/02/15:20
 * @Description: kafka监听器
 */
@Component
@Slf4j
public class WemediaNewsAutoListener {

    @Resource
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;
    @KafkaListener(topics = NewsAutoScanConstants.WM_NEWS_AUTO_SCAN_TOPIC)
    public void handleNewsAutoScanMsg(String newsId){
        log.info("自动审核方法被调用==> newsId: {}",newsId);
        if(StringUtils.isNotBlank(newsId)){
            wemediaNewsAutoScanService.autoScanByMediaNewsId(Integer.valueOf(newsId));
            log.info("自动审核方法调用结束==> newsId: {}",newsId);
        }
    }
}
